package com.intco.ait.quotation.api.starter.web;

import com.intco.ait.quotation.api.infrastructure.mybatis.entity.encodingPlatform.MaterialCodingPropertyWithItems;
import com.intco.ait.quotation.api.infrastructure.mybatis.entity.menu.MaterialCodingProperty;
import com.intco.ait.quotation.api.infrastructure.mybatis.mapper.MenuConfigMapper;
import com.intco.ait.quotation.api.infrastructure.service.BomService;
import com.intco.ait.quotation.api.infrastructure.service.SkuDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/menu")
public class MenuConfigController {

    @Autowired
    private MenuConfigMapper mapper;

    @Autowired
    private SkuDataService skuDataService;

    @Autowired
    private BomService bomService;

    @GetMapping("/materialClass")
    public List<Map<String, Object>> materialClass() {
        return mapper.getMaterialClass();
    }

    @GetMapping("/propertiesWithItemsByClassId")
    public List<MaterialCodingPropertyWithItems> propertiesWithItemsByClassId(Integer classId) {
        return mapper.getPropertiesWithItemsByClassId(classId);
    }

    @GetMapping("/propertiesRawByClassId")
    public List<MaterialCodingProperty> propertiesRawByClassId(Integer classId) {
        return mapper.getPropertiesByClassId(classId);
    }

    @GetMapping("/bom/products")
    public List<String> bomProducts() {
        List<String> products = skuDataService.getProducts();
        products.add(0, "通用");
        return products;
    }

    @GetMapping("/bom/products/class")
    public List<String> bomProductsClass(String productType) {
        return bomService.getClassesByProductType(productType);
    }

    @GetMapping("/sku/products")
    public List<String> skuProducts() {
        return skuDataService.getProducts();
    }


}
